package com.sanjiahantang.ythshopping.presenter;

import android.content.Context;

import com.sanjiahantang.ythshopping.config.ConfigValue;
import com.sanjiahantang.ythshopping.http.BaseDelegate;
import com.sanjiahantang.ythshopping.http.ExceptionHelper;
import com.sanjiahantang.ythshopping.http.OkHttpClientManager;
import com.sanjiahantang.ythshopping.model.EvaluateModle;
import com.sanjiahantang.ythshopping.utils.Utils;
import com.sanjiahantang.ythshopping.views.EvaluateView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/6/27.
 */

public class EvaluateListPresenter extends BasePresenter {
    Context context;
    EvaluateView view;
    int page;


    public EvaluateListPresenter (Context context,EvaluateView view)
    {
        this.context=context;
        this.view=view;
        page = 1;
    }

    public void LoadEvaluateList(String type,int page)
    {
        initLoadDialog(context);
        mLoadingDialog.show();
        Map<String,String> params=new HashMap<>();
        params.put("key", ConfigValue.DATA_KEY);
        params.put("page",page+"");
        params.put("state",type);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "msg/myComments", params, new BaseDelegate.ResultCallback<EvaluateModle>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                dismiss();
                Utils.showToast(context, ExceptionHelper.getMessage(e, context));
            }

            @Override
            public void onResponse(EvaluateModle response, Object tag) {
                dismiss();
                view.getEvaluateList(response);
            }
        });
    }

}
